package com.be.beadmin.logging.controller;

import com.be.beadmin.logging.entity.Log;
import com.be.beadmin.common.entity.PageEntity;
import com.be.beadmin.logging.service.LogService;
import com.be.beadmin.logging.dto.input.LogQueryCriteria;
import com.be.beadmin.logging.dto.input.LogDto;
import org.springframework.data.domain.Pageable;
import com.be.beadmin.common.utils.ResultModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
* @author chenwei
* @date 2022-12-27
**/
@RestController
public class LogController {

    @Autowired
    private  LogService logService;


    @PostMapping(value = "/logging/getLogByPage")
    public ResultModel getLogByPage(@RequestBody PageEntity pageEntity)  {
        return ResultModel.success(logService.getLogByPage(pageEntity)) ;
    }

    @PostMapping("/logging/addLog")
    public ResultModel addLog(@RequestBody LogDto logDto){
        logService.addLog(logDto);
        return ResultModel.success(ResultModel.ADD);
    }

    @PostMapping("/logging/delLog")
    public ResultModel delLog(@RequestBody LogDto logDto){
        logService.delLog(logDto.getId());
        return ResultModel.success(ResultModel.DELETE);
    }


    @PostMapping("/logging/updateLog")
    public ResultModel updateLog(@RequestBody LogDto logDto){
        logService.updateLog(logDto);
        return ResultModel.success(ResultModel.UPDATE);
    }
}